#region Copyright and License Notice
// Copyright (C)2010-2016 - Rob Levine and other contributors
// http://configgen.codeplex.com
// 
// This file is part of ConfigGen.
// 
// ConfigGen is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// ConfigGen is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License and 
// the GNU Lesser General Public License along with ConfigGen.  
// If not, see <http://www.gnu.org/licenses/>
#endregion

using System;
using System.IO;
using ConfigGen.Core.ConfigurationSettings;
using ConfigGen.Core.TemplateLoader;
using ConfigGen.Core.TemplateProcessing;

namespace ConfigGen.Core
{
    /// <summary>
    /// Interface implemented by <see cref="SingleFileGenerator"/>.
    /// </summary>
    public interface ISingleFileGenerator
    {
        /// <summary>
        /// Initialises the current instance using the arguments provided.
        /// </summary>
        /// <param name="currentMachine">Settings for the curent machine configuration being generated.</param>
        /// <param name="tokenCounts">Token count collections, containing counts of unused and unrecognised tokens.</param>
        /// <param name="templatePreferences">Template preferences.</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the supplied arguments are null.</exception>
        void Initialise(
            MachineConfigurationSettings currentMachine, 
            TokenCounts tokenCounts,
            TemplatePreferences templatePreferences);

        /// <summary>
        /// Processes the supplied template source stream using the supplied template processor and writes the output onto
        /// the supplied processed template stream. This process is responsible for processing any custom configgen elements and
        /// attributes such as the applyWhen attribute. 
        /// </summary>
        /// <param name="sourceUnprocessedTemplateStream">Stream containing the unprocessed template source.</param>
        /// <param name="templateProcessor">Template processor.</param>
        /// <param name="targetProcessedTemplateStream">Stream onto which the target template is written.</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the supplied arguments are null.</exception>
        void ProcessTemplate(
            Stream sourceUnprocessedTemplateStream,
            ITemplateProcessor templateProcessor, 
            Stream targetProcessedTemplateStream);

        /// <summary>
        /// Replaces the tokens in the template with the tokens from the settings collection for the machine config being generated.
        /// </summary>
        /// <param name="sourceProcessedTemplateStream">Source processed template stream, being the processed template stream
        /// generated by <see cref="SingleFileGenerator.ProcessTemplate"/>.</param>
        /// <param name="targetConfigStream">The target stream on which to write the generated config file.</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the supplied arguments are null.</exception>
        void ReplaceTokens(
            Stream sourceProcessedTemplateStream,
            Stream targetConfigStream);
    }
}